﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NewstorePlateformeDAO
{
    public partial class GOLD_EMPLOYE
    {
        /// <summary>
        /// Retourne la liste complète des employés Newstore, les anciens employés inclus
        /// </summary>
        /// <returns></returns>
        public static List<GOLD_EMPLOYE> GetAll()
        {
            List<GOLD_EMPLOYE> result = new List<GOLD_EMPLOYE>();

            using (Newstore_PL_GOLD_BDDEntities context = new Newstore_PL_GOLD_BDDEntities(EntitiesHelper.connexionString))
            {
                result = (from employe in context.GOLD_EMPLOYE
                          select employe).ToList();
            }

            return result;
        }

        /// <summary>
        /// Retourne la liste complète des employés Newstore actifs
        /// </summary>
        /// <returns></returns>
        public static List<GOLD_EMPLOYE> GetAllActive()
        {
            List<GOLD_EMPLOYE> result = new List<GOLD_EMPLOYE>();

            using (Newstore_PL_GOLD_BDDEntities context = new Newstore_PL_GOLD_BDDEntities(EntitiesHelper.connexionString))
            {
                result = (from employe in context.GOLD_EMPLOYE
                          where employe.DateDepart == null
                          select employe).ToList();
            }

            return result;
        }

        /// <summary>
        /// Retourne l'employé spécifié à l'identifiant renseigné.
        /// </summary>
        /// <param name="id">L'identifiant del'employé recherché.</param>
        /// <returns></returns>
        public static GOLD_EMPLOYE Get(int id)
        {
            GOLD_EMPLOYE result = null;

            using (Newstore_PL_GOLD_BDDEntities context = new Newstore_PL_GOLD_BDDEntities(EntitiesHelper.connexionString))
            {
                result = (from employe in context.GOLD_EMPLOYE
                          where employe.idGOLD_EMPLOYE == id
                          select employe).FirstOrDefault();
            }

            return result;
        }
    }
}
